<template>
  <div>
    <template v-if="offlineRule && offlineRule.length > 0">
      <el-collapse v-model="activeNames">
        <el-collapse-item
          :title="item.name"
          :name="index + 1"
          v-for="(item, index) in offlineRule"
          :key="index"
        >
          <zm-form class="ml20">
             <zm-form-item label="选择影院：">
              <zm-button v-if="item.relationType === '1'" type="text" @click="onLookCinemaName(item.relationId,item.relationName)">{{item.relationName}}</zm-button>
              <span v-else>{{item.relationName}}</span>
            </zm-form-item>
            <zm-form-item
              :label="`${i.label}：`"
              v-for="(i, idx) in dataList"
              :key="idx + 'data'"
            >
              {{ item[i.key] }}
            </zm-form-item>
            <zm-form-item label="可兑换票价范围：">
              大于等于{{ item.minPrice }} 元小于等于 {{ item.maxPrice }} 元
            </zm-form-item>
            <!-- 补差规则 start -->
            <zm-form-item label="补差规则：">
              {{
                getRuleType(item.ruleType)
              }}
            </zm-form-item>
            <div class="ml60" v-if="+item.ruleType === 2">
              {{
                getDiffPriceType(item.diffPriceType)
              }}
            </div>
            <div v-if="+item.diffPriceType === 2">
              固定价格：{{ item.fixedPrice }} 元
            </div>
            <div v-if="+item.diffPriceType === 3">
              加价价格：{{ item.fixedPrice }} 元
            </div>
            <!-- 补差规则 end -->
            <set-price-table
              v-if="
                +item.ruleType === 3 &&
                item.rule &&
                item.rule.length > 0
              "
              :data="item.rule"
              disabled
              :y-axis="item.copyType"
              :x-axis="item.hallType"
            ></set-price-table>
          </zm-form>
        </el-collapse-item>
      </el-collapse>
    </template>
    <h3 class="fc9" v-else>暂无数据</h3>
     <!-- 查看影院 -->
    <look-cinema v-if="paramsObj.visible" v-model="paramsObj.visible" :obj="paramsObj.obj"></look-cinema>
  </div>
</template>

<script>
import tableMixin from '@/mixins/zmTableMixin'
import { dataList } from './const'
import useRuleMixin from '../useRuleMixin'
import SetPriceTable from '@/components/SetPriceTable'

export default {
  name: 'OfflineBaseDetail',
  components: {SetPriceTable},
  mixins: [tableMixin, useRuleMixin],
  inject: ['$detail'],
  data () {
    return {
      activeNames: [1]
    }
  },
  computed: {
    offlineRule () {
      return this.$detail.infoData.offlineRule
    },
    dataList () {
      return dataList(this)
    }
  },
  watch: {},
  created () {},
  methods: {
    getRuleType (type) {
      const TypeObj = {
        1: '不设置补差',
        2: '差额补差',
        3: '固定补差'
      }
      return TypeObj[+type]
    },
    getDiffPriceType (type) {
      const TypeObj = {
        1: '超过券面值时补差',
        2: '超过固定价格时补差',
        3: '影院结算价 - 券面值+ X 元',
        5: '票价 - 券面值+ X 元'
      }
      return TypeObj[+type]
    }
  }
}
</script>

<style scoped lang='scss'>
</style>
